#!/bin/sh

# if im-select already exist, delete it and download it again
# if [ -e /usr/local/bin/im-select ]; then
# 	rm -f /usr/local/bin/im-select
# fi

echo "* Downloading im-select..."

if [ "$(uname -m)" = "arm64" ]; then
	if [ -e /opt/homebrew/bin/im-select ]; then
		rm -f /opt/homebrew/bin/im-select
	fi
	curl -Ls -o /opt/homebrew/bin/im-select https://gitee.com/hevey88/im-select/raw/master/macOS/out/apple/im-select
	chmod 777 /opt/homebrew/bin/im-select
else
	if [ -e /usr/local/bin/im-select ]; then
		rm -f /usr/local/bin/im-select
	fi
	curl -Ls -o /usr/local/bin/im-select https://gitee.com/hevey88/im-select/raw/master/macOS/out/intel/im-select
	chmod 777 /usr/local/bin/im-select
fi


echo "* im-select is installed!"
echo "*"
echo "*"
echo "*"
echo "* now run \"im-select\" in your terminal!"
